package com.zim.access.infrastructurre.protocol;

import com.zim.access.infrastructurre.protocol.api.Protocol;
import com.zim.access.infrastructurre.protocol.api.Provider;
import org.springframework.beans.factory.annotation.Autowired;

import java.net.URI;
import java.util.List;

/**
 * @author hanyue
 * @version 1.0
 * @date 2021/12/21 下午10:56
 */
public class DefaultProtocol implements Protocol {

    @Autowired
    private List<Protocol> protocols;

    @Override
    public Provider ref(URI url) {
        for (Protocol protocol : protocols) {
            if (protocol instanceof DefaultProtocol) {
                continue;
            }

            Provider provider = protocol.ref(url);
            if (provider != null) {
                return provider;
            }
        }

        // TODO 该协议不支持
        return null;
    }
}
